# Maintainer: Ryuta Suzuki <oroppas@gmail.com>

_realname=networkx
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=3.4.2
pkgrel=1
pkgdesc="High-productivity software for complex networks (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
license=('spdx:BSD-3-Clause')
url="https://networkx.org/"
msys2_repository_url="https://github.com/networkx/networkx"
msys2_references=(
  'archlinux: python-networkx'
  'purl: pkg:pypi/networkx'
  "cpe: cpe:2.3:a:python:networkx"
)
depends=("${MINGW_PACKAGE_PREFIX}-python")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-build"
             "${MINGW_PACKAGE_PREFIX}-python-installer"
             "${MINGW_PACKAGE_PREFIX}-python-setuptools")
checkdepends=("${MINGW_PACKAGE_PREFIX}-python-pytest"
              "${MINGW_PACKAGE_PREFIX}-python-pytest-cov")
optdepends=("${MINGW_PACKAGE_PREFIX}-python-numpy"
            "${MINGW_PACKAGE_PREFIX}-python-scipy"
            "${MINGW_PACKAGE_PREFIX}-python-matplotlib"
            "${MINGW_PACKAGE_PREFIX}-python-pandas")
source=("https://pypi.org/packages/source/${_realname::1}/${_realname}/${_realname}-${pkgver}.tar.gz")
sha256sums=('307c3669428c5362aab27c8a1260aa8f47c4e91d3891f48be0141738d8d053e1')

build() {
  cp -r "${_realname}-${pkgver}" "python-build-${MSYSTEM}" && cd "python-build-${MSYSTEM}"
  ${MINGW_PREFIX}/bin/python -m build --wheel --skip-dependency-check --no-isolation
}

check() {
  cd "${srcdir}"/python-build-${MSYSTEM}
  ${MINGW_PREFIX}/bin/python -m pytest || warning "Tests failed"
}

package() {
  cd "${srcdir}"/python-build-${MSYSTEM}
  MSYS2_ARG_CONV_EXCL="--prefix=" \
    ${MINGW_PREFIX}/bin/python -m installer --prefix=${MINGW_PREFIX} \
    --destdir="${pkgdir}" dist/*.whl

  install -D -m644 LICENSE.txt "${pkgdir}"${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE
}
